import time

from django.core.management.base import BaseCommand
from service.shedule_optimisation.optimiser import Optimiser
from service.models import Month, Event, PredictionFact
from django.core.management import call_command
from service.fill_service_data_from_xlsx import get_data_from_xlsx
from service.prediction_service import PredictionService
from users import models
from datetime import datetime
from random import randint


class Command(BaseCommand):
    help = 'Optimise'

    def handle(self, *args, **kwargs):
        models.User.objects.exclude(is_superuser=True).delete()
        Event.objects.all().delete()
        call_command('loaddata', "initial_users_fixture.json")

        month = Month.objects.get(month=2, year=2024)
        Optimiser(month).optimise_work()


